﻿using System;

namespace Batman.CommandLine
{
    class Program
    {
        static void Main(string[] args)
        {
            var thisAssembly = typeof(Program).Assembly;
            var typeList = typeof(Program).Assembly.ExportedTypes;
            foreach (var type in typeList)
            {
                if (type.BaseType == typeof(CommandLineApplicationBase))
                {
                    var instance = thisAssembly.CreateInstance(type.FullName, false) as CommandLineApplicationBase;
                    
                    if (args.Length > 0 && instance.Name.Equals(args[0], StringComparison.OrdinalIgnoreCase))
                    {
                        instance.Execute(args);
                    }
                }
            }
        }
    }
}
